/*
 * Cmd.scala
 */

package acorn.jash

import java.io.File
import java.lang.System._

abstract class Cmd extends Expr {

  override final def eval:Int = {
    try {
      exec;
      0
    }
    catch {
      case je:JashException => {err putln je.getMessage;1}
      case e:Exception => throw e
    }
  }

  /**
   * Execute the command.
   */
  protected def exec:Unit

}

object Cmd {
  def throwCNF(cmd:String) =
    throw new JashException(cmd + ": command not found.")
}

